﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

/// <summary>
/// Summary description for CalculatePremiumBLL
/// </summary>
public class CalculatePremiumBLL
{
	public CalculatePremiumBLL()
	{
		//
		// TODO: Add constructor logic here
		//
	}

    CalculatePremiumDAL dal = new CalculatePremiumDAL();

    public decimal getPremium(String relationship,int age,String plan,int level,Decimal discount,String productType)
    {
        decimal premium = dal.getPremium(relationship,plan, age);


        if (productType.StartsWith("H"))
        {
            decimal rate = getHospitalLevelRate(level);
            premium = premium * (1 + rate);
        }
        else
        {
            decimal rate = getAccidentLevelRate(level);
            premium = premium * (1 + rate);

        }


        return premium;
    }

    private decimal getHospitalLevelRate(int level)
    {
        decimal rate = 0;
        switch (level)
        {
            case 1: rate = 0;
                break;
            case 2: rate = 0.20M;
                break;
            case 3: rate = 0.30M;
                break;
            case 4: rate = 0.40M;
                break;
            case 5: rate = 0.50M;
                break;

        }

        return rate;

    }

    private decimal getAccidentLevelRate(int level)
    {
        decimal rate = 0;
        switch (level)
        {
            case 1: rate = 0;
                break;
            case 2: rate = 0.50M;
                break;
            case 3: rate = 0.80M;
                break;
            case 4: rate = 1.00M;
                break;

        }

        return rate;

    }
}